<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:param name="languageCode">1033</xsl:param>
  <xsl:template match="/entity/form">
    <table width="100%" height="100%" cellspacing="0" cellpadding="0">
      <tr height="25">
        <td>
          <table cellspacing="0" cellpadding="0" class="tabBar">
            <tr>
              <td id="tabs" nowrap="" valign="bottom" style="padding-left: 1px;">
                <xsl:for-each select="tabs/tab">
                  <span onclick="SetActiveObject();" ondblclick="ViewPropertiesNow();">
                    <xsl:attribute name="class">tab<xsl:if test="position() = 1"> tabOn</xsl:if></xsl:attribute>
                    <xsl:attribute name="tabID">tab<xsl:value-of select="position() - 1" /></xsl:attribute>
                    <xsl:attribute name="name">
                      <xsl:value-of select="@name" />
                    </xsl:attribute>
                    <xsl:value-of select="labels/label[@languagecode = $languageCode]/@description" />
                  </span>
                </xsl:for-each>
              </td>
            </tr>
          </table>
          <hr id="hrSelectedTab" class="tabGlow" />
          <hr id="hrGlowTab" class="tabGlow" />
        </td>
      </tr>
      <tr>
        <td id="tabContent" valign="top">
          <xsl:for-each select="tabs/tab">
            <div class="tab">
              <xsl:attribute name="id">tab<xsl:value-of select="position() - 1" /></xsl:attribute>
              <xsl:if test="position() = 1">
                <xsl:attribute name="style">display: inline;</xsl:attribute>
              </xsl:if>
              <xsl:for-each select="sections/section">
                <table cellspacing="4" cellpadding="4" class="section" onclick="SetActiveObject();" ondblclick="ViewPropertiesNow();" style="table-layout: fixed;">
                  <xsl:attribute name="name">
                    <xsl:value-of select="@name" />
                  </xsl:attribute>
                  <col />
                  <col />
                  <tr>
                    <td colspan="2" class="section">
                      <xsl:if test="@showlabel = 'false'">
                        <xsl:attribute name="style">color: #cccccc;</xsl:attribute>
                      </xsl:if>
                      <xsl:if test="@showbar = 'true'">
                        <xsl:attribute name="style">border-bottom: 1px solid #606050;</xsl:attribute>
                      </xsl:if>
                      <xsl:value-of select="labels/label[@languagecode = $languageCode]/@description" />
                    </td>
                  </tr>
                  <xsl:for-each select="rows/row">
                    <tr>
                      <xsl:choose>
                        <!--
												cell spans both columns
											-->
                        <xsl:when test="not(cell[2])">
                          <xsl:apply-templates select="cell[1]">
                            <xsl:with-param name="colspan">true</xsl:with-param>
                          </xsl:apply-templates>
                        </xsl:when>
                        <xsl:otherwise>
                          <xsl:choose>
                            <xsl:when test="cell[1]/@name">
                              <xsl:apply-templates select="cell[1]" />
                            </xsl:when>
                            <xsl:otherwise>
                              <td>
                              </td>
                            </xsl:otherwise>
                          </xsl:choose>
                          <xsl:choose>
                            <xsl:when test="cell[2]/@name">
                              <xsl:apply-templates select="cell[2]" />
                            </xsl:when>
                            <xsl:otherwise>
                              <td>
                              </td>
                            </xsl:otherwise>
                          </xsl:choose>
                        </xsl:otherwise>
                      </xsl:choose>
                    </tr>
                  </xsl:for-each>
                </table>
              </xsl:for-each>
            </div>
          </xsl:for-each>
        </td>
      </tr>
    </table>
  </xsl:template>
  <xsl:template match="/entity/form/tabs/tab/sections/section/rows/row/cell">
    <xsl:param name="colspan" />
    <xsl:variable name="fieldName" select="@name" />
    <td class="cell">
      <xsl:if test="$colspan">
        <xsl:attribute name="colspan">2</xsl:attribute>
      </xsl:if>
      <xsl:attribute name="name">
        <xsl:value-of select="@name" />
      </xsl:attribute>
      <xsl:attribute name="datatype">
        <xsl:value-of select="/entity/metadata/fields/field[@name = $fieldName]/@datatype" />
      </xsl:attribute>
      <table cellspacing="0" cellpadding="0" class="cell" style="table-layout: fixed;">
        <col width="115" />
        <col />
        <tr>
          <td nowrap="" class="label">
            <xsl:choose>
              <xsl:when test="/entity/metadata/fields/field[@name = $fieldName and @requiredforplatform = 'true'] or /entity/properties/fields/field[@name = $fieldName and @requiredlevel = 'required']">
                <xsl:attribute name="class">label req</xsl:attribute>
              </xsl:when>
              <xsl:when test="/entity/properties/fields/field[@name = $fieldName and @requiredlevel = 'recommended']">
                <xsl:attribute name="class">label rec</xsl:attribute>
              </xsl:when>
            </xsl:choose>
            <xsl:value-of select="labels/label[@languagecode = $languageCode]/@description" />
          </td>
          <td nowrap="" class="field">
            <xsl:value-of select="/entity/properties/fields/field[@name = $fieldName]/displaynames/displayname[@languagecode = $languageCode]/@description" />
          </td>
        </tr>
      </table>
    </td>
  </xsl:template>
</xsl:stylesheet>